package com.qo.qsdk.ui.base;

import android.app.Activity;
import android.view.View;

import com.qo.qsdk.model.UserModel;
import com.qo.qsdk.ui.QSDKListener;
import com.qo.qsdk.utils.DynamicUtils;
import com.qo.qsdk.utils.Language;
import com.qo.qsdk.utils.QSDKHelper;

import com.qo.qsdk.ui.base.third.Px7TextView;
import com.qo.qsdk.ui.base.third.Px9TextView;
import com.qo.qsdk.ui.base.third.Px9EditText;
import com.qo.qsdk.ui.base.third.StrokeTextView;
import com.qo.qsdk.ui.base.third.StrokeTextViewY;

public class ExitView {

    private Px9TextView mAccount;
    private StrokeTextView mBtn;
    private Activity mActivity;
    private QSDKListener mQSDKListener;

    public ExitView(Activity mActivity, QSDKListener qsdkListener) {
        this.mActivity = mActivity;
        this.mQSDKListener = qsdkListener;
        this.mActivity.setContentView(DynamicUtils.layout(this.mActivity, "qsdk_exit"));
        init(mActivity);
    }

    private void init(Activity v) {
        mAccount = v.findViewById(DynamicUtils.id(mActivity, "loadingAccount"));
        mBtn = v.findViewById(DynamicUtils.id(mActivity, "loadingBtn"));
        mBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mQSDKListener != null) mQSDKListener.onExitSuccess();
            }
        });
        v.findViewById(DynamicUtils.id(mActivity, "close")).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mQSDKListener != null) mQSDKListener.onExitCancel();
            }
        });
        refresh();
    }

    public void show(Activity activity) {
        refresh();
    }

    private void refresh() {
        UserModel userModel = QSDKHelper.getInstance().getUserInfoModel(this.mActivity);
        mAccount.setText(userModel.getAccount());
        mBtn.setText(Language.Exit_Btn.toString());
    }
}
